<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xsl:stylesheet SYSTEM "lang://mail">

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	
	
	<xsl:include href="../main.xsl" />
	<xsl:include href="../menu.xsl" />
	<xsl:include href="../common/navigation.xsl" />
	<xsl:include href="commentsList.xsl" />

	<xsl:template match="data/response">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
			<link rel="stylesheet" href="{$baseURI}/css/mail.css" type="text/css" media="all" />
			<link rel="stylesheet" href="{$baseURI}/css/comments.css" type="text/css" media="all" />
			<script type="text/javascript" src="{$baseURI}/js/mail.js" />
			<script type="text/javascript" src="{$baseURI}/js/baseComments.js" />
			<script type="text/javascript" src="{$baseURI}/js/mailComments.js" />
		</head>
		<body>
			
			<xsl:call-template name="top-userbar" />

			<div id="header">
				<xsl:call-template name="logo" />

				<xsl:call-template name="menu" />
			</div>

			<div id="blocks">
				<div id="blocks_inner">
					<xsl:call-template name="default-blocks-top" />
				</div>
			</div>

			<div id="content">
				<div id="content_inner">
					<xsl:apply-templates select="object" />
				</div>
			</div>

			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	
	<xsl:template match="object[@type='message']">
		<xsl:param name="senderLogin" select="property[@name='sender_login']/value" />
		
		<div id="mail_message">
			<h1>
				<a href="{$baseURI}/mail">&labelMail;</a>
				<xsl:text> → </xsl:text>
				<span class="subject">
					<xsl:value-of select="property[@name='subject']/value" />
				</span>
			</h1>
			
			<div id="mail_message_body">
				<xsl:value-of select="property[@name='text']/value" disable-output-escaping="yes" />
			</div>
			
			<div style="clear:both;" />
			<div id="mail_message_info">
				<div id="mail_message_info_inner">
					<div>
						<xsl:value-of select="property[@name='date']/value" />
					</div>
					<div id="u_link">
						<a href="{$baseURI}/user/{$senderLogin}">
							<xsl:value-of select="property[@name='sender_name']/value" />
						</a>
					</div>
					<div id="delete_message">
						<a onclick="if(!confirm('&labelDeleteConfirm;')) return false;" href="{$baseURI}/mail/delete?delete[{@type-id}][]={@id}">&labelDelete;</a>
					</div>
				</div>
			</div>
		</div>
		
		<a name="comments" />
		<h3 class="comments">&labelReplies; (<xsl:value-of select="property[@name='count_comments']/value" />):</h3>
		
		<div id="comments_div">
			<xsl:apply-templates select="document(concat('xmodule://mail/getcomments/', @id))/data/response" mode="comments" />
		</div>
		
	</xsl:template>
	
	<xsl:template match="object[@type='system_notification']">
		<div id="mail_message">
			<h1>
				<a href="{$baseURI}/mail">&labelMail;</a>
				<xsl:text> → </xsl:text>
				<span class="subject">
					<xsl:value-of select="property[@name='subject']/value" />
				</span>
			</h1>
			
			<div id="mail_message_body">
				<xsl:value-of select="property[@name='text']/value" disable-output-escaping="yes" />
			</div>
			
			<div style="clear:both;" />
			<div id="mail_message_info">
				<div id="mail_message_info_inner">
					<div>
						<xsl:value-of select="property[@name='date']/value" />
					</div>
					<div>
						<xsl:text>&labelNotification;</xsl:text>
					</div>
					<div id="delete_message">
						<a onclick="if(!confirm('&labelDeleteConfirm;')) return false;" href="{$baseURI}/mail/delete?delete[{@type-id}][]={@id}">&labelDelete;</a>
					</div>
				</div>
			</div>
		</div>		
	</xsl:template>
	
</xsl:stylesheet>